package com.ling.pl.autoproject.definition.dao;

import com.ling.pl.core.commons.constant.TableColnumDef;
import com.ling.pl.core.commons.utils.AssertHelper;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author bo.wang
 */
@Component(ProgrammeDao.BEAN_ID)
public class ProgrammeDao extends BaseProgrammeDao {
    protected void buildProgrammeQuery(StringBuffer query, Map values, Map params) {
        query.append(" from ProgrammeEntity where 1=1 ");
        Object value = params.get("flag");
        if (AssertHelper.notEmpty(value)) {
            query.append(" and flag=:flag");
            values.put("flag", value);
        } else {
            query.append(" and flag=:flag");
            values.put("flag", TableColnumDef.FLAG_EFFECT);
        }
        if (AssertHelper.notEmpty(TableColnumDef.FILTER_NAME_PATTERN)) {
            //			query.append(" and status=:status");
            //			values.put("status", value);
        }
    }

    protected void buildProjectQuery(StringBuffer query, Map values, Map params) {
        query.append(" from ProjectEntity where 1=1 ");
        Object value = params.get("programmeId");
        if (AssertHelper.notEmpty(value)) {
            value = value.toString();
            query.append(" and programmeId=:programmeId");
            values.put("programmeId", value);
        }
        value = params.get("flag");
        if (AssertHelper.notEmpty(value)) {
            query.append(" and flag=:flag");
            values.put("flag", value);
        } else {
            query.append(" and flag=:flag");
            values.put("flag", TableColnumDef.FLAG_EFFECT);
        }
        if (AssertHelper.notEmpty(TableColnumDef.FILTER_NAME_PATTERN)) {
//			query.append(" and status=:status");
//			values.put("status", value);
        }
    }
}

